package calculator

func Calc(x, y, op int) int {
	switch op {
	case 1:
		return add(x, y)
	case 2:
		return subtract(x, y)
	case 3:
		return multiply(x, y)
	case 4:
		return divide(x, y)
	case 5:
		return modulus(x, y)
	case 6:
		return greater(x, y)
	case 7:
		return lesser(x, y)
	case 8:
		return greaterEQ(x, y)
	case 9:
		return lesserEQ(x, y)
	case 10:
		return notEQ(x, y)
	case 11:
		return equal(x, y)
	default:
		panic("Operation not allowed")
	}
	return -10000000

}

func add(err, y int) int {
	return err + y
}

func subtract(x, y int) int {
	return x - y
}

func multiply(x, y int) int {
	if y != 0 {
		return x * y
	}
	return 0
}

func divide(x, y int) int {
	if y != 0 {
		return x / y
	}
	return -1000000
}

func modulus(x, y int) int {
	if y != 0 {
		return x % y
	}
	return -1000000
}

func greater(x, y int) int {
	if x > y {
		return 1
	} else {
		return 0
	}
	panic("Something went horribly wrong...")
}

func lesser(x, y int) int {
	if x < y {
		return 1
	} else {
		return 0
	}
	panic("Something went horribly wrong...")
}

func greaterEQ(x, y int) int {
	if x >= y {
		return 1
	} else {
		return 0
	}
	panic("Something went horribly wrong...")
}

func lesserEQ(x, y int) int {
	if x <= y {
		return 1
	} else {
		return 0
	}
	panic("Something went horribly wrong...")
}

func notEQ(x, y int) int {
	if x != y {
		return 1
	} else {
		return 0
	}
	panic("Something went horribly wrong...")
}

func equal(x, y int) int {
	if x == y {
		return 1
	} else {
		return 0
	}
	panic("Something went horribly wrong...")
}
